﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double a = double.Parse(this.textBox1.Text);
            double b = double.Parse(this.textBox2.Text);
            string s = this.comboBox1.SelectedItem.ToString();
            double end = 1d;
            switch (s)
            {
                case "+":
                    end = a + b;
                    break;
                case "-":
                    end = a - b;
                    break;
                case "*":
                    end = a * b;
                    break;
                case "/":
                    if (b == 0)
                    {
                        this.textBox3.Text = "除数为0";
                    }
                    else
                    {
                        end = a / b;
                    }
                    break;
                case "^":
                    for (int i = 0; i < b; i++)
                    {
                        end *= a;
                    }
                    break;
            }
            this.textBox3.Text = end.ToString();
        }

        private void textBox1_Click(object sender, EventArgs e)
        {
            this.textBox1.Clear();
        }

        private void textBox2_Click(object sender, EventArgs e)
        {
            this.textBox2.Clear();
        }
    }
}
